package com.ruoyi.vehicleDispatch.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.vehicleDispatch.domain.ForceDispatchSetting;
import com.ruoyi.vehicleDispatch.service.IForceDispatchSettingService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 强制派单设置Controller
 * 
 * @author niuyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/setting")
public class ForceDispatchSettingController extends BaseController
{
    @Autowired
    private IForceDispatchSettingService forceDispatchSettingService;

    /**
     * 查询强制派单设置列表
     */
    @RequiresPermissions("vehicleDispatch:setting:list")
    @GetMapping("/list")
    public TableDataInfo list(ForceDispatchSetting forceDispatchSetting)
    {
        startPage();
        List<ForceDispatchSetting> list = forceDispatchSettingService.selectForceDispatchSettingList(forceDispatchSetting);
        return getDataTable(list);
    }

    /**
     * 导出强制派单设置列表
     */
    @RequiresPermissions("vehicleDispatch:setting:export")
    @Log(title = "强制派单设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ForceDispatchSetting forceDispatchSetting)
    {
        List<ForceDispatchSetting> list = forceDispatchSettingService.selectForceDispatchSettingList(forceDispatchSetting);
        ExcelUtil<ForceDispatchSetting> util = new ExcelUtil<ForceDispatchSetting>(ForceDispatchSetting.class);
        util.exportExcel(response, list, "强制派单设置数据");
    }

    /**
     * 获取强制派单设置详细信息
     */
    @RequiresPermissions("vehicleDispatch:setting:query")
    @GetMapping(value = "/{settingId}")
    public AjaxResult getInfo(@PathVariable("settingId") Integer settingId)
    {
        return success(forceDispatchSettingService.selectForceDispatchSettingBySettingId(settingId));
    }

    /**
     * 新增强制派单设置
     */
    @RequiresPermissions("vehicleDispatch:setting:add")
    @Log(title = "强制派单设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ForceDispatchSetting forceDispatchSetting)
    {
        return toAjax(forceDispatchSettingService.insertForceDispatchSetting(forceDispatchSetting));
    }

    /**
     * 修改强制派单设置
     */
    @RequiresPermissions("vehicleDispatch:setting:edit")
    @Log(title = "强制派单设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ForceDispatchSetting forceDispatchSetting)
    {
        return toAjax(forceDispatchSettingService.updateForceDispatchSetting(forceDispatchSetting));
    }

    /**
     * 删除强制派单设置
     */
    @RequiresPermissions("vehicleDispatch:setting:remove")
    @Log(title = "强制派单设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{settingIds}")
    public AjaxResult remove(@PathVariable Integer[] settingIds)
    {
        return toAjax(forceDispatchSettingService.deleteForceDispatchSettingBySettingIds(settingIds));
    }
}
